<?php

/**
 * Created by PhpStorm.
 * User: yandian
 * Date: 2017/3/27
 * Time: 20:19
 */

namespace app\common\model;

use app\common\services\LoginService;
use think\Model;

class BaseModel extends Model
{
    /**
     * @return static
     */
    public static function instance()
    {
        static $instance = null;
        if (empty($instance)) {
            $instance = new static();
        }
        return $instance;
    }

    public function ofLoginUser($field = 'id')
    {
        $this->where([$field => LoginService::getLoginUserId()]);
        return $this;
    }

    public function gotoPage($page = null, $pageSize = 10)
    {
        if(is_null($page)){
            $page = I('get.p',1,'intval');
        }
        $this->page($page,$pageSize);
        return $this;
    }
}